package com.quanquan.store.controller;

import com.quanquan.store.entity.ShoppingKillTradingRecord;
import com.quanquan.store.request.ShoppingKillRecordRequestBody;
import com.quanquan.store.service.ShoppingKillTradingRecordService;
import enums.ResCodeEnum;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import web.response.ResultBody;

import java.util.List;

/**
 * 功能描述:
 *
 * @ClassName: ShoppingKillTradingRecordController
 * @Author: xiaoqianh丶
 * @Date: 2019-07-09 14:29
 * @Version: V1.0
 */
@RestController
@RequestMapping("/shopping_kill_record")
public class ShoppingKillTradingRecordController {

    private final ShoppingKillTradingRecordService shoppingKillTradingRecordService;

    public ShoppingKillTradingRecordController(ShoppingKillTradingRecordService shoppingKillTradingRecordService) {
        this.shoppingKillTradingRecordService = shoppingKillTradingRecordService;
    }

    @PostMapping("/query")
    public ResultBody queryTradingRecord(@RequestBody ShoppingKillRecordRequestBody requestBody){
        Integer page = requestBody.getPage() == null ? 0 : requestBody.getPage();
        Integer size = requestBody.getSize() == null ? 100 : requestBody.getSize();
        String userId = requestBody.getUserId();
        List<ShoppingKillTradingRecord> shoppingKillTradingRecords = shoppingKillTradingRecordService.queryAllRecord(userId,page,size);
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), ResCodeEnum.SUCCESS.getMsg(), com.alibaba.fastjson.JSONObject.toJSON(shoppingKillTradingRecords));

    }



}
